package com.huiying.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huiying.annotation.AutoFile;
import com.huiying.entity.entity.User;
import com.huiying.entity.vo.FollowVO;
import com.huiying.entity.vo.UserVO;
import com.huiying.utils.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: lsh
 * @Date: 2024/10/25/22:13
 * @Description:
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据openid查询
     * @param openId
     * @return: com.fx.entity.User
     */
    @Select("select id, openid, username, gender, birthday, avatar, phone, role, name, " +
            "id_number, wx_number, wx_qrcode, create_time, update_time, " +
            "province, city, bio, district from user where openid = #{openId}")
    User getByOpenid(String openId);

    /**
     * 插入新用户
     * @param user
     * @return: void
     */
    @AutoFile(OperationType.INSERT)
    void insertUser(User user);

    /**
     * 根据id查询
     * @param id
     * @return: com.fx.entity.User
     */
    UserVO getById(Long id);

    /**
     * 修改用户信息
     * @param user
     * @return: void
     */
    @AutoFile(OperationType.UPDATE)
    void update(User user);


    @Select("select username,avatar,gender,role,city from user where id = #{id}")
    FollowVO getFollow(Long id);

    /**
     * 根据id列表批量查询
     * @param idList
     * @return: java.util.List<com.fx.vo.FollowVO>
     */
    List<FollowVO> getFollowBatch(List<Long> idList);

    List<String> getAvatarBatch(List<Long> UserIdList);
}
